Skip to content

only assign default values if we have the block field info#1613

Merged
angrybrad merged 1 commit into5.xfrom
bugfix/1607-matrix-default-values-and-other-arrays
Apr 17, 2025
Merged

only assign default values if we have the block field info#1613
angrybrad merged 1 commit into5.xfrom
bugfix/1607-matrix-default-values-and-other-arrays

Conversation

@i-just
Copy link
Contributor

@i-just i-just commented Mar 28, 2025

Description

When importing into a Matrix field and “Use default value” is used for any of its subfields, if you also have at least one more arrayable value in the feed that contains more items than the number of blocks/entries that should be imported into the matrix field, extra blocks/entries were being created (using that default value).

Steps to reproduce:

  • CMS v4 or v5 installation with Feed Me installed
  • create a matrix field with at least one block and at least 2 fields in the block (can be two plain text fields, plainText, secondPlainText)
  • create a section that uses this matrix field
  • create a json feed (example data below) that imports to that section:
    • strategy: create, update
    • primary element: entries
    • map the title to title
    • map matrix > plainText to myMatrix/MatrixBlock/plainText1
    • map matrix > secondPlainText to Use default value, default value: my default text
  • save and run the feed
  • in control panel, go to the edit page for my entry 1 and note that it contains 3 blocks/entries in the matrix field
{
  "entries": [
    {
      "title": "my entry 1",
      "myMatrix": {
        "MatrixBlock": [
          {
            "plainText1": "text1"
          },
          {
            "plainText1": "text2"
          }
        ]
      },
      "myArray1": ["one", "two", "three"]
    }
  ]
}

Related issues

#1607

@i-just i-just requested a review from angrybrad as a code owner March 28, 2025 09:07
@angrybrad angrybrad merged commit eac131a into 5.x Apr 17, 2025
6 checks passed
@angrybrad angrybrad deleted the bugfix/1607-matrix-default-values-and-other-arrays branch April 17, 2025 03:04
angrybrad added a commit that referenced this pull request Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants